﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class service_xgmm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["username"] != null && Session["userpwd"] != null)
            {
                this.hidName.Value = Session["username"].ToString();
                this.lblUser.Text = Session["username"].ToString();
            }
            else
            {
                Response.Redirect("service_self.aspx");
            }
        }
    }
    /// <summary>
    /// 修改密码
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void imgbtnxgmm_Click(object sender, ImageClickEventArgs e)
    {
        string userName = Session["username"].ToString();
        string oldPwd = Session["userpwd"].ToString();
        string newPwd = this.unpwd.Text;
         string code = (string)Session["code"];
        string c = this.code.Text;
        if (c.Trim().ToLower() == code.Trim())
        {
            try
            {
                emoneybussiness.emoneybusiness service = new emoneybussiness.emoneybusiness();
                string result = service.ChangePassWord(userName, oldPwd, newPwd);
                if (result == "密码修改成功")
                {
                    this.unpwd.Text = "";
                    this.code.Text = "";
                    ClientScript.RegisterStartupScript(GetType(), "a", "alert('" + result + "');", true);
                }
                else
                {
                    ClientScript.RegisterStartupScript(GetType(), "a", "alert('密码修改失败');", true);
                }

            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(GetType(), "a", "alert('服务器忙，请重试');", true);
            }
        }
        else
        {
            ClientScript.RegisterStartupScript(GetType(), "a", "alert('验证码输入不正确');", true);
        }
    }
}